package com.agou.app.admin.business.user.action;

import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import com.agou.core.ss.SSException;
import com.agou.core.ss.SSTrace;
import com.agou.ssh.core.base.BOResultSet;
import com.opensymphony.xwork2.Action;

public class UserAjaxAction extends IUserAjaxAction {
	
	private static final long serialVersionUID = -6570449486103195596L;
	private static SSTrace ssTrace = SSTrace.getInstance(UserAjaxAction.class);
	
	/** ***********输出参数************* **/
	private Map<String, Object> dataset = new HashMap<String, Object>();

	public Map<String, Object> getDataset() {
		return dataset;
	}

	public void setDataset(Map<String, Object> datamap) {
		this.dataset = datamap;
	}
	
	/**
	 * 用户注册
	 * 
	 * @return
	 * @throws SSException
	 * @throws SQLException
	 * @throws IOException
	 */
	public String userRegister() throws SSException, SQLException, IOException {
		try {
			ssTrace.debug("userRegister", "用户注册：#0", userVo);
			this.jdbcBeging(true, true);// 设置使用事务，并且自动管理
			this.getUserBo().setJdbcSession(this.getJdbcSession());// bo对象如果使用数据库操作，需要进行初始化
			BOResultSet boResultSet = this.getUserBo().userRegister(userVo);
			if (boResultSet.IsSuccess == true) {// 用户注册成功
				dataset.put("success", true);
				dataset.put("return_info", "注册成功");
			}else{
				dataset.put("success", false);
				dataset.put("return_info", boResultSet.ReturnInfo);
				dataset.put("bo_userlogin", boResultSet);
			}
			return Action.SUCCESS;// 用户注册错误
		} catch (Throwable e) {
			e.printStackTrace();
			dataset.put("success", false);
			dataset.put("return_info", "异常:" + e.getMessage());
			this.destroyInError();//
			return Action.SUCCESS;// 用户注册错误
		} finally {
			this.destroy();//
		}
	}
}
